typedef struct {
unsigned short state;
+ unsigned short override;
} extra_data;
static
}
else if (!(lon1 <= lon3 && lon2 <= lon3)) {
/* we're inside the bbox of a diagonal line. math time. */
- double loni = (lon2-lon1)/(lat2-lat1)*(lat3-lat1);
+ double loni = lon1+(lon2-lon1)/(lat2-lat1)*(lat3-lat1);
if ( loni > lon3 ) {
*state = *state ^ INSIDE;
}
else {
ed = xcalloc(1, sizeof(*ed));
ed->state = OUTSIDE;
+ ed->override = 0;
waypointp->extra_data = ed;
}
+ if ( lat2 == waypointp->latitude &&
+ lon2 == waypointp->longitude ) {
+ ed->override = 1;
+ }
if ( olat != BADVAL && olon != BADVAL &&
olat == lat2 && olon == lon2 ) {
last = 1;
ed = wp->extra_data;
wp->extra_data = NULL;
if ( ed ) {
+ if ( ed->override ) ed->state = INSIDE;
if (((ed->state & INSIDE) == OUTSIDE ) == (exclopt == NULL)) {
waypt_del(wp);
waypt_free(wp);